
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/dist/query/react";

export const loginApi = createApi({
    reducerPath: 'loginApi',
    //设置基本请求路径
    baseQuery: fetchBaseQuery({
        baseUrl: window.app
    }),

    endpoints(build) {
        return {

            //登录请求
            postlogin: build.mutation({
                query(data) {
                    return {
                        url: 'Login/Login',
                        method: 'POST',
                        body: data
                    };
                },
                transformResponse(baseQuery) {
                    return baseQuery;

                }
            }),
            //登录请求
            postlogout: build.mutation({
                query(data) {
                    return {
                        url: 'Login/Logout',
                        method: 'POST',
                        body: data
                    };
                },
                transformResponse(baseQuery) {
                    return baseQuery;

                }
            }),

        }
    }
});


//导出钩子函数给外部使用，自动生成hooks的名称为`use(Endpoint_name)Query`
export const { usePostloginMutation, usePostlogoutMutation } = loginApi;